package designMode.strategyPatter;

import com.luli.entity.MsgResult;

/**
 * 陆离
 * 2023/11/6 10:37:03
 * 抽象类
 */
// 定义支付逻辑，具体支付交由子类实现
public abstract class Payment {
    public abstract String getName();
    //通用逻辑放到抽象类里面实现
    public MsgResult pay(String uid, double amount) {
        //余额是否足够
        if (queryBalance(uid) < amount) {
            return new MsgResult(500, "支付失败", "余额不足");
        }
        return new MsgResult(200, "支付成功", "支付金额" + amount);
    }
    protected abstract double queryBalance(String uid);
}